package com.cx.polymorphism;

import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Function;

/**
 * @Author:cxy
 * @Date:2022/3/6 20:07
 */
public class Human<T extends Human<T>> {

    private T t;

    public Human() {
    }

    public Human(T t) {
        this.t = t;
    }

    public T getT() {
        return t;
    }

    public void setT(T t) {
        this.t = t;
    }

    public static void main(String[] args) {

        Human<?> h = new Human<>();

        final ArrayList<Integer> list = new ArrayList<>();

        execuTime((a) -> getEx());

        new Human<>().<String>printer("cxy",(q1)-> q1.concat(q1.length()+""));


        final Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("Human.run");
            }
        });
        thread.start();
        thread.start();
        thread.start();


    }

    public <R> void printer(R t,Function<R,String> function){
        System.out.println(function.apply(t));
    }

    public static void getEx(){
       try {
            TimeUnit.SECONDS.sleep(0);
            System.out.println("这里睡了2秒");
       } catch (InterruptedException e) {
           e.printStackTrace();
       }
    }

    public static <T> void execuTime(Consumer<T> consumer){
        final long l = System.currentTimeMillis();
        consumer.accept(null);
        System.out.println((System.currentTimeMillis() - l) + " ms");
    }


}
